import { getUser } from '../service';

type stateType = {
  user: any[];
};
const model = {
  namespace: 'cm',
  state: {
    user: [],
  } as stateType,
  reducers: {
    saveUser(state, { payload }) {
      return { ...state, user: payload.list };
    },
  },
  effects: {
    *fetchUser({ payload }, { call, put, select }): any {
      const { data } = yield call(getUser);
      yield put({
        type: 'saveUser',
        payload: data,
      });
    },
  },
};
export default model;
